package com.eightbears.beboy.base.view.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager;
import android.widget.TextView;

import com.eightbears.beboy.R;

/**
 * @创建者 Administrator
 * @创建时间 Created by Administrator on 2017/3/20.
 * @描述 选择类别对话框，用于经历认证页面（选选择分类对话框）
 * @更新 $Author$
 * @更新时间 2017/3/20
 * @更新描述 ${TODO}.
 */

public class ClassDialog extends Dialog implements View.OnClickListener {
    private onDialogItemClickListener itemClickListener = null;
    private Context mContext;
    private TextView mTv_d_sauna;
    private TextView mtv_sauna;
    private TextView mtv_ktv;
    private TextView mtv_muzhu;
    private TextView mtv_jiuba;
    private TextView mtv_zonghui;
    private TextView mtv_qita;

    public ClassDialog(Context context) {
        super(context);
        this.mContext = context;
    }

    public ClassDialog(Context context, boolean cancelable, OnCancelListener cancelListener, Context mContext) {
        super(context, cancelable, cancelListener);
        this.mContext = mContext;
    }

    public ClassDialog(Context context, int theme) {
        super(context, theme);
        this.mContext = context;
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_class);
        initView();
        initEvent();
    }

    private void initView() {

        mtv_sauna = (TextView) findViewById(R.id.tv_sauna);
        mtv_ktv = (TextView) findViewById(R.id.tv_ktv);
        mtv_muzhu = (TextView) findViewById(R.id.tv_muzhu);
        mtv_jiuba = (TextView) findViewById(R.id.tv_jiuba);
        mtv_zonghui = (TextView) findViewById(R.id.tv_zonghui);
        mtv_qita = (TextView) findViewById(R.id.tv_qita);
        getWindow().setGravity(Gravity.CENTER);
        WindowManager.LayoutParams LayoutParams = getWindow().getAttributes();
//        LayoutParams.width = 550;
//        LayoutParams.height = 300;
//        LayoutParams.alpha = 0.9f;
        getWindow().setAttributes(LayoutParams);

    }

    private void initEvent() {
        mtv_sauna.setOnClickListener(this);
        mtv_ktv.setOnClickListener(this);
        mtv_muzhu.setOnClickListener(this);
        mtv_jiuba.setOnClickListener(this);
        mtv_zonghui.setOnClickListener(this);
        mtv_qita.setOnClickListener(this);
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tv_sauna:
                String s = mtv_sauna.getText().toString();
                if (itemClickListener != null) {
                    itemClickListener.onItemClick(s, "1");
                }
                break;
            case R.id.tv_ktv:
                String k = mtv_ktv.getText().toString();
                if (itemClickListener != null) {
                    itemClickListener.onItemClick(k, "2");
                }
                break;
            case R.id.tv_muzhu:
                String m = mtv_muzhu.getText().toString();
                if (itemClickListener != null) {
                    itemClickListener.onItemClick(m, "3");
                }
                break;
            case R.id.tv_jiuba:
                String j = mtv_jiuba.getText().toString();
                if (itemClickListener != null) {
                    itemClickListener.onItemClick(j, "4");
                }
                break;
            case R.id.tv_zonghui:
                String z = mtv_zonghui.getText().toString();
                if (itemClickListener != null) {
                    itemClickListener.onItemClick(z, "5");
                }
                break;
            case R.id.tv_qita:
                String q = mtv_qita.getText().toString();
                if (itemClickListener != null) {
                    itemClickListener.onItemClick(q, "12");
                }
                break;
        }
    }


    public void setOnItemClickListener(onDialogItemClickListener listener) {

        this.itemClickListener = listener;
    }

    public interface onDialogItemClickListener {

        void onItemClick(String s, String id);
    }

}
